// 验证模块
const Joi = require('joi');
// 用户模块
const {
	Room
} = require('../../../model/Room');
// 工具
const _ = require('lodash');

module.exports = async (req, res) => {
	const _id = req.params['id'];
	if (await res.isFakeID(_id)) return;
	// 通过验证
	const {
		_id: {},
		...roomInfo
	} = req.fields;
	// 更新房间信息
	// new: true 返回修改后的文档 默认值为false 返回原始文档
	let room = await Room.findByIdAndUpdate(_id, {
		$set: roomInfo
	}, {
		new: true
	});
	// 响应
	res.sendResult(room, 200, '更新房间成功');
};